<?php

class Core_Agent_Component_Password_View_ChangePassword_Index extends Core_Agent_Share_View_Form {

    protected function buildToolbar($toolbar) {
        $group = $toolbar->createGroup('save');
        $group = $toolbar->createGroup('back');
        $group->addLink($this->getUrl(null,'index','index','index'), $this->__('share.button.back'));
        $group->addButton($this->__('share.button.save'))
        	  ->bindEvent('click', "Kdf.Ui.getForm('".$this->getForm()->getId()."').submit('".$this->getUrl(null, 'changePasswordPost')."')");
        
        parent::buildToolBar($toolbar);
    }

    protected function buildForm($form) {
        $entity = $this->getModel(NULL);
        $form->setAction($this->getUrl())
                ->setId('content_form')
                ->addHiddenField('id', 'content[id]');
        $form->addPasswordField($this->__('share.label.oldpassword'), 'oldpassword', 'content[oldpassword]', TRUE)
                ->addMinLengthRule('6');
        $form->addPasswordField($this->__('share.label.newpassword'), 'newpassword', 'content[newpassword]', TRUE)
                ->addMinLengthRule('6');
        $form->addPasswordField($this->__('share.label.repassword'), 'repassword', "content[repassword]", TRUE)
               ->addMinLengthRule('6')->addValidateRule('equalTo','newpassword');
        $form->addValidateCodeField($this->__('share.label.validate_code'), 'validate_code', 'content[validate_code]');
        parent::buildForm($form);
    }

}